﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CustomLable.aspx.cs" Inherits="UI_Bas_CustomLable" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>CustomLable维护</title>
    <link href="../../css/admin.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery.easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery.easyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery.easyui/jquery.min.js" type="text/javascript"></script>
    <script src="../../js/jquery.easyui/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery.easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
  
    <script type ="text/javascript" >
        function filter(str) {
            str = str.replace(/\+/g, "%2B");
            str = str.replace(/\&/g, "%26");
            return str;
        }
       var defaultDate = Date.parse('1900/01/01');
       $(function () {
           var _$customlablemapping = $("#customlablemapping");
           _$customlablemapping.datagrid({
               border: true,
               height: 750,
               title: 'CustomLable列表...',
               remoteSort: false,
               nowrap: true,
               striped: false,
               url: "../../TableHanders.aspx?act=q&tid=28&type=0",
               pageSize: 30,
               sortName: 'CustomerId',
               sortOrder: 'desc',
               loadMsg: "正在加载,请稍后...",
               toolbar: [{
               //2013-10-16 ,Cancel ADD function
                   text: 'Add',
                   iconCls: 'icon-add',
                   handler: function () {
                       window.location.href = "CustomLableDetail.aspx?act=I";
                       return false;
                   }
               }],

               frozenColumns: [[

                    { field: 'opt', title: 'Operation', width: 95, align: 'center',
                        formatter: function (val, row, index) {
                            var Id = row.CustomerId;
                            return '<a href="#" onclick = "DeleteRow(this);" id = ' + filter(Id) + ' rowIndex = ' + index + ' style="color:red;">Delete</a>  '

                                + '<a href = "CustomLableDetail.aspx?act=e&id=' + filter(Id) + '">  Eidt</a>';
                            //2013-10-16 ,Cancel Copy function
                                                            + '<a href = "CustomLableDetail.aspx?act=c&id=' + filter(Id) + '" style="color:Blue;">  Copy</a>';
                        }
                    },
	                { title: 'Customer编号', field: 'CustomerId', width: 260, sortable: true }
				  ]],
               columns: [[
                    { title: 'Listing', field: 'Listing', width: 200, sortable: true },
	                { title: '包裹类型', field: 'PackageId', width: 90, sortable: true, formatter: function (val) {
	                    if (val == 40027) {
	                        return "letter";
	                    }
	                    else if (val == 40028) {
	                        return "largerletter";
	                    }
	                    else if (val == 40029) {
	                        return "packet";
	                    }
	                    else if (val == 40079) {
	                        return "ctlargeletter";
	                    }
	                    else if (val == 40081) {
	                        return "mediumpacket";
	                    }
	                    else {
	                        return val;
	                    }
	                }
	                },
	                { title: '仓库', field: 'Wh_Code', width: 120, sortable: true },
                    { title: '登陆方式', field: 'SellingFormat', width: 120, sortable: true },
                    { title: '登陆国家', field: 'LogonCountry', width: 120, sortable: true },
	                { title: '操作时间', field: 'Mtime', width: 120, sortable: true, formatter: function (val) {
	                    var d = Date.parse(val.replace("-", "/"));
	                    if (d == defaultDate) {
	                        return "";
	                    }
	                    else {
	                        return val;
	                    }
	                }
	                }
				]],

               pagination: true,
               rownumbers: true,
               singleSelect: true,
               pageList: [10, 15, 30, 50, 100]
           });

           $("#btnQuery").click(function () {
               if (!$("#divContent").form('validate'))
                   return;
               var packageType = $("#ddlPackageId").val();
               var warehouseId = $("#ddlWh_Code").val();
               var cuslable = $("#txtCusLable").val();
               _$customlablemapping.datagrid({
                   queryParams: {
                       "packageId": packageType,
                       "wh_Code": warehouseId,
                       'cuslable': cuslable
                   }
               });
           });
       }); 
   
       function DeleteRow(row) {
            var rowAttr = $(row);
            var id = rowAttr.attr('id');           
            var rowIndex = rowAttr.attr('rowIndex');
            $.messager.confirm("请确认...", "确认删除?", function(value) {
                if (value) {
                    var url = "../../TableHanders.aspx?act=d&tid=28&type=1&id=" + id;
                    $.getJSON(
                        url,
                        function(data) {
                            var sdata = data[0];
                            var code = sdata.code;
                            if (code == 0) {
                                $("#customlablemapping").datagrid('deleteRow', rowIndex);
                            }
                            else {
                                alert(sdata.msg);
                            }
                        }
                    );
                }
            });            
          }
    </script>	
</head>
<body> 
  <input type="hidden"  id="tid1" runat="server"/>
  <div class="div_Title">
        <span class="Body_Title">》》<%=this.Title %></span>
  </div>
  <div id="divContent" class="easyui-panel" title="请输入查询条件..." style="margin-bottom:5px;">      
    <form id="formQuery" runat="server">        
       <table >
             <tr>       
                <td >CusLable:</td>
                <td >
                   <input id="txtCusLable" runat="server" class="easyui-validatebox"  style ="width:100px;"/>
                </td>          
                <td >包裹类型:</td>
                <td >
                   <select id="ddlPackageId" runat="server" class="easyui-validatebox"  style ="width:100px;"/>
                </td>
                <td >发货仓库:</td>
                <td >
                   <select id="ddlWh_Code" runat="server" class="easyui-validatebox" enableviewstate="false" />
                </td>
                 <td>
                   <a id="btnQuery"  href ="#"  class="easyui-linkbutton" icon="icon-search" >Query</a>
                </td>
            </tr>            
         </table>
       </form>
    </div>
    <table  id="customlablemapping"></table>     
</body>
</html>